From 9ab43dfe9e58b669fed76483aa7ecde51655c37c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Sat, 6 May 2017 17:05:58 +0200 Subject: [PATCH] spinbutton: Add accessors for (max-)width-chars --- docs/reference/gtk/gtk4-sections.txt | 4 +++ gtk/gtkspinbutton.c | 45 ++++++++++++++++++++++++++++ gtk/gtkspinbutton.h | 12 ++++++++ 3 files changed, 61 insertions(+) diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index 04704a4b5c..1bc1d5ea05 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -2741,6 +2741,10 @@ gtk_spin_button_get_value gtk_spin_button_get_wrap gtk_spin_button_set_text gtk_spin_button_get_text +gtk_spin_button_set_max_width_chars +gtk_spin_button_get_max_width_chars +gtk_spin_button_set_width_chars +gtk_spin_button_get_width_chars GTK_INPUT_ERROR GTK_SPIN_BUTTON diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index 9dca8ae7f1..488bca623c 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -2305,3 +2305,48 @@ gtk_spin_button_set_text (GtkSpinButton *spin_button, g_object_notify (G_OBJECT (spin_button), "text"); } + +int +gtk_spin_button_get_max_width_chars (GtkSpinButton *spin_button) +{ + GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button); + + g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), -1); + + return gtk_entry_get_width_chars (GTK_ENTRY (priv->entry)); +} + + +void +gtk_spin_button_set_max_width_chars (GtkSpinButton *spin_button, + int max_width_chars) +{ + GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button); + + g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); + + gtk_entry_set_max_width_chars (GTK_ENTRY (priv->entry), max_width_chars); + g_object_notify (G_OBJECT (spin_button), "max-width-chars"); +} + +int +gtk_spin_button_get_width_chars (GtkSpinButton *spin_button) +{ + GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button); + + g_return_val_if_fail (GTK_IS_SPIN_BUTTON (spin_button), -1); + + return gtk_entry_get_width_chars (GTK_ENTRY (priv->entry)); +} + +void +gtk_spin_button_set_width_chars (GtkSpinButton *spin_button, + int width_chars) +{ + GtkSpinButtonPrivate *priv = gtk_spin_button_get_instance_private (spin_button); + + g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); + + gtk_entry_set_width_chars (GTK_ENTRY (priv->entry), width_chars); + g_object_notify (G_OBJECT (spin_button), "width-chars"); +} diff --git a/gtk/gtkspinbutton.h b/gtk/gtkspinbutton.h index 5dc3b7cd0e..b811b5f9a1 100644 --- a/gtk/gtkspinbutton.h +++ b/gtk/gtkspinbutton.h @@ -232,6 +232,18 @@ const char * gtk_spin_button_get_text (GtkSpinButton *spin_button); GDK_AVAILABLE_IN_3_92 void gtk_spin_button_set_text (GtkSpinButton *spin_button, const char *text); +GDK_AVAILABLE_IN_3_92 +int gtk_spin_button_get_max_width_chars (GtkSpinButton *spin_button); +GDK_AVAILABLE_IN_3_92 +void gtk_spin_button_set_max_width_chars (GtkSpinButton *spin_button, + int max_width_chars); +GDK_AVAILABLE_IN_3_92 +int gtk_spin_button_get_width_chars (GtkSpinButton *spin_button); +GDK_AVAILABLE_IN_3_92 +void gtk_spin_button_set_width_chars (GtkSpinButton *spin_button, + int width_chars); + + G_END_DECLS -- 2.30.2